<?php

namespace App\Console\Commands\Chanjet;

use App\Http\Controllers\Chanjet\TplusCommonController;
use App\Models\Chanjet\TplusToken;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

class OtherOutbound extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:OtherOutbound';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '获取Tplus数据-其他出库单';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }
//    public function business_type(){
//        $businessType = [
//            'TplusOtherInboundOrder' => '其他入库单', //其他入库单
//            'TplusOtherOutboundOrder' => '其他出库单',//其他出库单
//            'TplusCountOrder'=>'盘点单',//盘点单
//            'TplusInboundAdjustmentOrder'=>'入库调整单',//入库调整单
//            'TplusOutboundAdjustmentOrder'=>'',//出库调整单
//            'TplusFeeCostShare',//采购费用分摊单
//            'TplusInventoryAgeAnalysis',//库龄分析
//            'TplusInventoryInfo',//存货明细账
//            'TplusInventoryLedger',//存货总账
//            'TplusInventoryTurnoverAnalysis',//库存周转率分析
//            'TplusPaymentDetail',//应付明细
//            'TplusPaymentLedger',//应付总账
//            'TplusPaymentOrder',//付款单
//            'TplusPurchaseInvoice',//采购发票
//            'TplusSaleInvoice',//销售发票
//            'TplusReceiptOrder',//收款单
//            'TplusReceiveDetail',//应收明细
//            'TplusReceiveLedger',//应收总账
//            'TplusSaleGrossProfitAnalysis',//销售毛利分析
//            'TplusSluggishInventoryAnalysis',//呆滞存货分析
//            'TplusTransferOrder',//调拨单
//        ];
//        return $businessType;
//    }
    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $TplusToken = TplusToken::where('is_valid',0)->select(['org_id','access_token'])->get();
        $common = new TplusCommonController();
        foreach ($TplusToken as $item) {
            $res = $common->getExternalData('TplusOtherOutboundOrder',$item['org_id'],[],$item['access_token']);
            //Log::info($this->description.",org_id:".$item['org_id'].",".$res['data']);
        }
        Log::info($this->description."执行成功");
        return 0;
    }
}
